<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"  %>
<%@taglib  prefix="c"  uri="http://java.sun.com/jsp/jstl/core"%>
 <jsp:include page="../header.jsp"></jsp:include>
<fieldset class="layui-elem-field layui-field-title">
  <legend>添加项目</legend> 
</fieldset>
<form action="project/add" method="post" class="layui-form">
	<div class="layui-form-item">
		<label class="layui-form-label">项目名字</label>
		<div class="layui-input-inline">
			<input type="text" name ="name" class="layui-input">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">开始时间</label>
		<div class="layui-input-inline">
			<input type="date" name="start" class="layui-input"/>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">结束时间</label>
		<div class="layui-input-inline">
			<input type="date" name="end"  class="layui-input"/>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">项目奖金</label>
		<div class="layui-input-inline">
			<input type="text" name ="bonus" class="layui-input">
		</div>
	</div>
	
	<div class="layui-form-item">
		<label class="layui-form-label">相关人员</label>
		<div class="layui-input-block" id="staff_list">
			
			
		</div>
	</div>
	
	<div class="layui-form-item">
		<label class="layui-form-label"></label>
		<div class="layui-input-inline">
			<input type ="submit" value="添加"  class="layui-btn layui-btn-primary layui-border-blue">
		</div>
		<div class="layui-form-mid layui-word-aux">${error}</div>
	</div>


</form>
<script type="text/javascript">
layui.use(['laydate','form'], function(){
	var form = layui.form;
	var laydate =layui.laydate;
	
	//渲染事件日期控件
	laydate.render({
    elem: 'input[name="pstart"]',
	});
	laydate.render({
	    elem: 'input[name="pend"]',//指定元素
		});
	$.ajax({ 
		url:'staff/getAll', // 请求地址
		type:'post', //请求类型 post get 
		data:{},//请求的参数
		dataType:'json',//返回数据的类型， text html xml json
		success: function(data){//请求成功后  调用当前的函数
			//服务器处理成功  返会的数据类型与dataType相同
			//data就是从服务器返回的数据
		 var html="";
		 //遍历部门
		 $.each(data,function(index,item){
			 html +='<input type="checkbox" name="staff_id" value="'+ item.id+'" title="'+item.name+'"  lay-skin="primary">' 
		 });
		 $("#staff_list").html(html);
		 form.render();
		},
		error:function(){
		//请求失败后  调用当前的函数
			alert("失败")
		}
	});
	});
</script>
<script type="text/javascript" src="js/jquery-2.1.4.js"></script>

 <jsp:include page="../footer.jsp"></jsp:include>
